<template>
  <div style="margin-left: 5px;margin-right: 5px;">
    <div style="margin-top: 1%;"></div>
    <!-- 表格 -->
    <el-table :data="tableData" stripe border style="width: 100%">
      <el-table-column prop="id" label="编号" width="auto">
      </el-table-column>
      <el-table-column prop="userId" label="用户编号" width="auto">
      </el-table-column>
      <el-table-column prop="algorithmId" label="算法编号">
      </el-table-column>
      <el-table-column prop="buyNumber" label="购买数量">
      </el-table-column>
      <el-table-column prop="insertTime" label="购买时间">
      </el-table-column>
      <el-table-column label="操作" width="auto" align="center">
        <template slot-scope="scope">
          <el-button type="primary" size="mini" icon="el-icon-edit" @click="editUserById(scope.row.id)">编辑
          </el-button>
          <strong style="font-size: 24px;">|</strong>
          <el-button type="danger" size="mini" icon="el-icon-delete" @click="deleteUserById(scope.row.id)">删除
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页 -->
    <el-pagination background :current-page="page" :page-size="limit" :total="total"
      style="padding: 30px 0; text-align: center;" layout="total, prev, pager, next, jumper"
      @current-change="queryOrder" />
  </div>
</template>

<script>
  import orderApi from '../../../api/cby/order.js'

  export default {
    data() {
      return {
        page: 1, // 当前页
        limit: 3, // 每页数量
        total: 0, // 总记录数
        cbyOrderQuery: {}, // 查询条件封装对象
        tableData: [],
      }
    },
    created() {
      this.queryOrder()
    },
    methods: {
      queryOrder(page = 1) {
        this.page = page
        orderApi.queryOrder(this.page, this.limit, this.cbyOrderQuery)
          .then((response) => {
            // 请求成功
            console.log(response.data)
            this.tableData = response.data.rows;
            this.total = response.data.total;
          })
          .catch((error) => {
            console.log(error);
          });
      },
      resetData() {
        this.cbyOrderQuery = {}
      },
    }
  }
</script>

<style>
</style>
